package mule.model;

//<editor-fold defaultstate="collapsed" desc="Imports">
//</editor-fold>
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;

/**
 * Singleton of the store, which only has an inventory
 *
 * @author stephen
 */
public class StoreModel 
{
    //<editor-fold defaultstate="collapsed" desc="Properties">

    private IntegerProperty food;
    private IntegerProperty energy;
    private IntegerProperty ore;
    private IntegerProperty muleCount;

    //</editor-fold>


    //<editor-fold defaultstate="collapsed" desc="Singleton Constructor">
    
    /**
     * Private constructor for the singleton of Store. The store is given a
     * default of 16 food, 16 energy, 0 ore, and 25 mules to start with.
     */
    private StoreModel()
    {
        this.food = new SimpleIntegerProperty( 16 );
        this.energy = new SimpleIntegerProperty( 16 );
        this.ore = new SimpleIntegerProperty( 0 );
        this.muleCount = new SimpleIntegerProperty( 25 );
    }

    /**
     * Getter for our StoreModel Singleton.
     * 
     * @return an instance of the MuleModel
     */
    public static StoreModel getInstance()
    {
        return StoreModelHolder.INSTANCE;
    }

    /**
     * Private class to implement a Singleton of our store Model.
     * 
     * #DESIGN_PRINCIPLE
     */
    private static class StoreModelHolder
    {
        private static final StoreModel INSTANCE = new StoreModel();    
    } 

    //</editor-fold>
    

    //<editor-fold defaultstate="collapsed" desc="Getters and Setters">
    
    /**
     * Returns the food property of the store as an IntegerProperty
     * 
     * @return the foodProperty for the store
     */
    public IntegerProperty foodProperty()
    {
        if( food == null )
        {
            food = new SimpleIntegerProperty( 0, "Default" );
        }

        return food;
    }

    /**
     * Returns the food the store has as an integer
     * 
     * @return the amount of food the store has
     */
    public int getFood()
    {
        return foodProperty().get();
    }

    /**
     * Sets the food in the store stockpile to a new value
     * 
     * @param food the amount of food to set for the store
     */
    public void setFood( int food )
    {
        foodProperty().set( food );
    }

    /**
     * Returns an IntegerProperty representation of the store energy
     * 
     * @return the energy of the store as an IntegerProperty
     */
    public IntegerProperty energyProperty()
    {
        if( energy == null )
        {
            energy = new SimpleIntegerProperty( 0, "Default" );
        }

        return energy;
    }

    /**
     * Returns an integer representation of the store energy
     * 
     * @return the energy of the store
     */
    public int getEnergy()
    {
        return energyProperty().get();
    }

    /**
     * Sets the energy of the store to a different value
     * 
     * @param energy the energy to set for the store
     */
    public void setEnergy( int energy )
    {
        energyProperty().set( energy );
    }

    /**
     * Returns an IntegerProperty representation of the store ore
     * 
     * @return The store ore as an integer property
     */
    public IntegerProperty oreProperty()
    {
        if( ore == null )
        {
            ore = new SimpleIntegerProperty( 0, "Default" );
        }

        return ore;
    }

    /**
     * Returns the ore that the store has as an integer
     * 
     * @return the amount of ore that the store has
     */
    public int getOre()
    {
        return oreProperty().get();
    }

    /**
     * Sets the ore to a value that is passed in for the store
     * 
     * @param ore The new amount of ore to set for the store
     */
    public void setOre( int ore )
    {
        oreProperty().set( ore );
    }

    /**
     * IntegerProperty representation of the number of mules contianed in the
     * store
     * 
     * @return Number of mules in the store as an Integer Property 
     */
    public IntegerProperty muleCountProperty()
    {
        if( muleCount == null )
        {
            muleCount = new SimpleIntegerProperty( 0, "Default" );
        }

        return muleCount;
    }

    /**
     * Returns the number of mules in the store
     * 
     * @return the number of mules in the store
     */
    public int getMuleCount()
    {
        return muleCountProperty().get();
    }

    /**
     * Sets the number of mules in the store
     * 
     * @param count the number of mules to set the store to have 
     */
    public void setMuleCount( int count )
    {
        muleCountProperty().set( count );
    }

    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="Methods for Testing">
    
    
    
}
